package com.s10.ecloud.web.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.s10.ecloud.web.Constants;
import com.s10.ecloud.web.model.DeviceModel;
import com.s10.ecloud.web.model.PageModel;
import com.s10.ecloud.web.model.User;
import com.s10.ecloud.web.service.IDeviceService;

public class DeviceModelCommandListAction extends ActionSupport {
	@Resource
	private IDeviceService deviceService;

	@Action(value = "/getDeviceModelCommandList", results = { @Result(name = "success", location = "/page/ent/deviceModelCommandListPage.jsp") })
	public String initDriverList() throws Exception {

		this.setPageModel();
		Object o = ActionContext.getContext().getSession().get("deviceModelId");

		if (o != null) {
			this.setDeviceModelId(Integer.parseInt(o.toString()));
		}

		this.setDeviceModel(deviceService.getDeviceModelByID(this.getDeviceModelId()));

		deviceService.getCommandPageModel(this.getPager(), this.getDeviceModelId());// 查询PageMode

		ActionContext.getContext().getSession().put("deviceModelId", this.getDeviceModelId());

		return this.SUCCESS;
	}

	public void setPageModel() {

		if (this.pager == null) {
			this.pager = new PageModel();
		}

		if (this.pager.getMaxPageItems() == 0) {
			this.pager.setMaxPageItems(10);
		}
	}

	private String functionCode;

	/**
	 * @return the functionCode
	 */
	public String getFunctionCode() {
		return functionCode;
	}

	/**
	 * @param functionCode
	 *            the functionCode to set
	 */
	public void setFunctionCode(String functionCode) {
		this.functionCode = functionCode;
	}

	private PageModel pager;

	/**
	 * @return the page
	 */
	public PageModel getPager() {
		return pager;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPager(PageModel pager) {
		this.pager = pager;
	}

	private int deviceModelId;

	public int getDeviceModelId() {
		return deviceModelId;
	}

	public void setDeviceModelId(int deviceModelId) {
		this.deviceModelId = deviceModelId;
	}

	private DeviceModel deviceModel;

	public DeviceModel getDeviceModel() {
		return deviceModel;
	}

	public void setDeviceModel(DeviceModel deviceModel) {
		this.deviceModel = deviceModel;
	}
}
